<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
    <script src="js/vue-router.js"></script>
    <style>
        li {
            list-style: none;
            margin: 20px 10px;
            display: inline-block;
        }

        a {
            text-decoration: none;
        }

        .show {
            width: 300px;
            height: 200px;
            background-color: #ccc;
        }
    </style>
</head>

<body>
    <div id="box">
        <nav>
            <ul>
                <li><router-link to='/home'>home</router-link></li>
                <li><router-link to='/news'>news</router-link></li>
                <li><router-link to='/hot'>hot</router-link></li>
            </ul>
            <div class="show">
                <router-view></router-view>
            </div>
        </nav>
    </div>
</body>

</html>
<script>
    var vm=new Vue({
        el:"#box",
        data:{},
        router:new VueRouter({
           routes:[
            {path:'',redirect:'/home'},
           {path:'/home',component:{template:'<h1>首页</h1>'}},
           {path:'/news',component:{template:'<h1>新闻</h1>'}},
           {path:'/hot',component:{template:'<h1>热门</h1>'}}
           ]
        })

    })

</script>